<template>
  <div>
    <div class="ser_div">
      <el-row>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 订单号 </el-col>
            <el-col :span="16">
              <el-input v-model="ser.order_number" type="number"></el-input>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 业主地址 </el-col>
            <el-col :span="16">
              <el-input v-model="ser.customer_name"></el-input>
            </el-col>
          </el-row>
        </el-col>
        <!-- <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 型号 </el-col>
            <el-col :span="16">
              <el-input v-model="ser.serial_number"></el-input>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 规格 </el-col>
            <el-col :span="16">
              <el-input v-model="ser.serial_number"></el-input>
            </el-col>
          </el-row>
        </el-col> -->
        <!-- <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 流水号 </el-col>
            <el-col :span="16">
              <el-input v-model="ser.serial_number"></el-input>
            </el-col>
          </el-row>
        </el-col> -->
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 客户 </el-col>
            <el-col :span="16">
              <el-select
                v-model="ser.customer_id"
                filterable
                placeholder="请选择客户"
                clearable
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in CustomerList"
                  :key="index"
                  :label="item.customer_name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 订单日期范围 </el-col>
            <el-col :span="16">
              <el-date-picker
                v-model="order_data"
                @change="order_data_change"
                value-format="yyyy-MM-dd"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-row style="display: flex; align-items: center">
            <el-col :span="8" style="text-align: center"> 状态 </el-col>
            <el-col :span="16">
              <el-select
                v-model="ser.logistics_status"
                placeholder="请选择物流状态"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in logistics_statuslist"
                  :key="index"
                  :label="item.lable"
                  :value="item.status"
                >
                </el-option>
              </el-select>
            </el-col>
          </el-row>
        </el-col>
        <el-col>
          <el-button
            @click="search(0)"
            class="add_btn"
            v-disPrevent
            icon="el-icon-search"
            >查询</el-button
          >
          <el-button @click="searchreset" icon="el-icon-refresh" class="add_btn"
            >重置</el-button
          >
          <el-button
            @click="exports_w"
            icon="el-icon-plus"
            class="add_btn"
            v-permission="['dingdan_daochu']"
            >导出</el-button
          >
          <!-- <el-upload class="upload-demo" :limit="1" :action="uploadUrl()" :auto-upload="false" :on-progress="progress"
            :on-change="handleExceed" :show-file-list="false" :headers="headers" :file-list="fileList">
            <el-button type="primary" icon="el-icon-plus" class="add_btn">导入订单</el-button>
          </el-upload> -->
          <el-button
            @click="add_color('ruleForm')"
            icon="el-icon-plus"
            class="add_btn"
            v-permission="['dingdan_add']"
            >新增订单</el-button
          >
          <!-- <el-button @click="prin" class="add_btn">打印任务单</el-button> -->
          <el-button type="primary" @click="Dayin_chuhuo(0)" class="add_btn"
            >打印出货单</el-button
          >
          <!-- <el-button type="primary" @click="prints()" class="add_btn">打印标签</el-button> -->
        </el-col>
      </el-row>
    </div>
    <!-- 勾选显示列 -->
    <!-- <el-row>
      <el-col :span="21" style="text-align: right;">
        <span style="padding-right:15px">列表显示字段</span>
        <el-cascader
        ref="cascader"
          v-model="permissions_arr"
          :options="options_order"
          :props="props"
          clearable
          collapse-tags
          @change="order_change"
        ></el-cascader>
      </el-col>
      <el-col :span="2"  style="text-align: right;">
        <el-button @click="push_permission">确定</el-button>
      </el-col>
    </el-row> -->
    <el-table
      :data="dataList"
      v-horizontal-scroll="'always'"
      v-loading="loading"
      stripe
      :row-key="getRowKeys"
      reserve-selection
       ref="multipleTable"
      default-expand-all
      style="width: 100%"
      border
     
      @selection-change="handleSelectionChange"
      @sort-change="sort_change"
    >
      <el-table-column type="expand">
        <template slot-scope="props">
          <el-table
            :data="props.row.order_second"
            style="margin-left: 30px"
            row-key="id"
            default-expand-all
            :tree-props="{ children: 'order_second' }"
          >
            <el-table-column label="产品" width="100">
              <template slot-scope="prop_s">
                <span>{{
                  prop_s.row.product ? prop_s.row.product.product_name : ""
                }}</span>
              </template>
            </el-table-column>
            <!-- <el-table-column label="是否拆分" width="150">
              <template slot-scope="prop_s">
                <span>{{ prop_s.row.is_split == 1 ? "是" : "否" }}</span>
              </template>
            </el-table-column> -->
            <el-table-column label="是否生产" width="80">
              <template slot-scope="prop_s">
                <span>{{ prop_s.row.is_needed == 1 ? "是" : "否" }}</span>
              </template>
            </el-table-column>
            <el-table-column label="型号" width="120">
              <template slot-scope="prop_s">
                <span>{{
                  prop_s.row.model_number
                    ? prop_s.row.model_number.model_number
                    : ""
                }}</span>
              </template>
            </el-table-column>
            <el-table-column label="颜色" width="100">
              <template slot-scope="prop_s">
                <span>{{
                  prop_s.row.color ? prop_s.row.color.color : ""
                }}</span>
              </template>
            </el-table-column>
            <el-table-column label="规格" width="150">
              <template slot-scope="prop_s">
                <span>{{
                  prop_s.row.specification
                    ? prop_s.row.specification.specification
                    : ""
                }}</span>
              </template>
            </el-table-column>
            <el-table-column label="尺寸" width="80" prop="work_size">
            </el-table-column>

            <el-table-column
              label="加减方式"
              width="150"
              prop="addition_subtraction"
            >
            </el-table-column>
            <el-table-column label="品牌" width="150" prop="brand">
            </el-table-column>
            <!-- <el-table-column label="方向" width="150" prop="direction">
            </el-table-column> -->

            <el-table-column label="数量" width="80" prop="num">
            </el-table-column>
            <el-table-column label="备注" prop="remark" width="250">
            </el-table-column>
            <el-table-column label="操作" width="300">
              <template slot-scope="scope">
                <el-button
                  type="text"
                  :disabled="scope.row.is_kucun == 1 || scope.row.is_split == 1"
                  @click="set_products(scope.row)"
                  >领单详情</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-table-column>

      <el-table-column type="selection" :reserve-selection="true">
      </el-table-column>
      <el-table-column
        prop="order_number"
        label="订单号"
        width="110"
        v-if="forEachs('order_number') || isshow"
      >
      </el-table-column>
      <!-- <el-table-column
        prop="serial_number"
        label="流水号"
        width="100"
        v-if="forEachs('serial_number') || isshow"
      >
      </el-table-column> -->
      <el-table-column
        label="客户"
        width="100"
        v-if="forEachs('customer_id') || isshow"
      >
        <template slot-scope="scope">
          <span>{{
            scope.row.customer ? scope.row.customer.customer_name : "备货"
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="customer_name" label="业主地址" width="120">
      </el-table-column>
      <el-table-column prop="customer_phone" label="业主电话" width="120">
      </el-table-column>
      <el-table-column
        v-if="forEachs('order_date') || isshow"
        prop="order_date"
        label="订单日期"
        :formatter="formatterTime"
        width="100"
      >
      </el-table-column>
      <!-- <el-table-column
        prop="remark"
        label="备注"
        width="120"
        v-if="forEachs('remark') || isshow"
      >
      </el-table-column> -->
      <el-table-column prop="customer" label="打印状态" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.is_print == 1">已打印</span>
          <span v-if="scope.row.is_print == 2">未打印</span>
        </template>
      </el-table-column>

      <el-table-column prop="received" label="生产状态" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.production_status == 1" style="color: #1b8bf5"
            >生产中</span
          >
          <span v-if="scope.row.production_status == 2" style="color: #e89207"
            >半成品</span
          >
          <span v-if="scope.row.production_status == 3" style="color: #1aa034"
            >生产完成</span
          >
          <span v-if="scope.row.production_status == 0" style="color: #ff6561"
            >未生产</span
          >
        </template>
      </el-table-column>
      <el-table-column prop="receivables" label="应收款" width="80">
      </el-table-column>
      <el-table-column prop="received" label="已收款" width="80">
        <template slot-scope="scope">
          <span>{{ scope.row.received }}</span>
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.other_remark"
            placement="top-start"
          >
            <i
              class="el-icon-s-flag float_icon"
              v-if="scope.row.order_color"
              :style="{ color: scope.row.order_color }"
            ></i>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column prop="discount" label="折扣" width="120">
      </el-table-column>
      <el-table-column label="尾款" width="120" prop="owe_price">
      </el-table-column>
      <el-table-column prop="pay_type" label="支付方式" width="100">
      </el-table-column>
      <el-table-column prop="received" label="发货状态" width="80">
        <template slot-scope="scope">
          <div v-if="scope.row.finish_product">
            <span
              v-if="scope.row.finish_product.logistics_status == 1"
              style="color: #dd8211"
              >待发货</span
            >
            <span
              v-if="scope.row.finish_product.logistics_status == 2"
              style="color: #f1420d"
              >未发货</span
            >
            <span
              v-if="scope.row.finish_product.logistics_status == 3"
              style="color: #0ca163"
              >已发货</span
            >
            <span
              v-if="scope.row.finish_product.logistics_status == 4"
              style="color: #c9be2f"
              >部分待发货</span
            >
            <span v-if="scope.row.logistics_status == 5" style="color: #c9be2f"
              >部分未发货</span
            >
            <span
              v-if="scope.row.logistics_status == 6"
              style="color: #4e4a4c; font-weight: bold"
              >已退货</span
            >
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-if="forEachs('delivery_date') || isshow"
        prop="delivery_date"
        label="发货日期"
        :formatter="formatterTime"
        width="100"
      >
      </el-table-column>
      <!-- <el-table-column label="是否分厂" width="130">
        <template slot-scope="scope">
          <span>{{ scope.row.branch_factory ? scope.row.branch_factory.name : '' }}</span>
        </template>
      </el-table-column> -->
      <el-table-column
        label="是否备货"
        width="80"
        v-if="forEachs('is_stock_up') || isshow"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.is_stock_up == 1">是</span>
          <span v-if="scope.row.is_stock_up == 2">否</span>
        </template>
      </el-table-column>

      <el-table-column
        label="业务员"
        v-if="forEachs('account_executive_id') || isshow"
      >
        <template slot-scope="scope">
          {{
            scope.row.account_executive
              ? scope.row.account_executive.company_name
              : ""
          }}
        </template>
      </el-table-column>
      <!-- <el-table-column prop="product_name" label="产品" width="80" v-if="forEachs('product_id') || isshow">
        <template slot-scope="scope">
          <span>{{ scope.row.product?scope.row.product.product_name:"" }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="num" label="数量" width="80"> </el-table-column>
      <el-table-column label="紧急程度" width="80" prop="emergency_procedure"
        v-if="forEachs('emergency_procedure') || isshow">
        <template slot-scope="scope">
          <span v-if="scope.row.emergency_procedure == 1" style="color: #333">普通</span>
          <span v-if="scope.row.emergency_procedure == 2" style="color: #1890ff; font-weight: bold">紧急</span>
          <span v-if="scope.row.emergency_procedure == 3" style="color: #ff0000; font-weight: bold">十万火急</span>
        </template>
      </el-table-column>
      <el-table-column label="成品价格" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.product_price">{{ scope.row.product_price }}</span>
          <span v-else>0</span>
        </template>
      </el-table-column>
      <el-table-column prop="received" label="发货价格" width="80">
        <template slot-scope="scope">
          <span v-if="scope.row.send_price">{{ scope.row.send_price }}</span>
          <span v-else>0</span>
        </template>
      </el-table-column> -->

      <!-- <el-table-column label="型号图片" width="100"  v-if="forEachs('model_number_id') || isshow">
        <template slot-scope="scope">
          <img
            :src="uploadImgUrl + scope.row.model_number.file.file_url"
            @click="push_img(scope.row)"
            style="
              cursor: pointer;
              display: block;
              width: 60px;
              display: block;
              margin: 0 auto;
            "
            v-if="scope.row.model_number.file != null"
          />
          <img
            src="../../../src/assets/zwtp.jpg"
            v-else
            style="width: 60px; display: block; margin: 0 auto"
          />
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        prop="color"
        label="颜色"
        width="80"
        v-if="forEachs('color_id') || isshow"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.color ? scope.row.color.color : "" }}</span>
        </template>
      </el-table-column> -->

      <!-- <el-table-column prop="customer" label="管理员" width="80" v-if="forEachs('account_executive_id') || isshow">
        <template slot-scope="scope">
          <span>{{ scope.row.admin_user && scope.row.admin_user.company_name }}</span>
        </template> 
      </el-table-column>-->

      <!-- <el-table-column
        label="是否补货"
        width="80"
        v-if="forEachs('is_replenishment') || isshow"
      >
        <template slot-scope="scope">
          <span v-if="scope.row.is_replenishment == 1">是</span>
          <span v-if="scope.row.is_replenishment == 2">否</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column
        prop="id"
        label="ID"
        width="70"
        v-if="forEachs('id') || isshow"
      >
        <template slot-scope="scope">
          <span v-if="!scope.row.edit">{{ scope.row.id }}</span>
        </template>
      </el-table-column> -->

      <!-- <div> -->
      <el-table-column
        v-for="(item, index) in dataList.models_field"
        :key="index"
        :prop="item"
        :label="push_name(item)"
      >
      </el-table-column>
      <!-- </div> -->
      <el-table-column label="操作" width="100" fixed="right">
        <template slot-scope="scope">
          <el-dropdown trigger="click">
            <el-button type="primary" size="small">
              操作<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <!-- <el-dropdown-item>
                <el-button @click="set_products(scope.row)" type="text" v-permission="['dingdan_lingdan_more']"
                  v-if="scope.row.is_replenishment == 2">领单详情</el-button>
              </el-dropdown-item> -->
              <el-dropdown-item>
                <el-button
                  v-permission="['dingdan_xiugai']"
                  @click="set_product(scope.row)"
                  type="text"
                  >编辑</el-button
                >
              </el-dropdown-item>
              <!-- <el-dropdown-item>
                <el-button @click="set_yishoukuan(scope.row)"
                  v-if="scope.row.finish_product ? scope.row.finish_product.logistics_status != 3 : false" type="text"
                  v-permission="['shezhi_yishoukuan']">设置已收款</el-button>
              </el-dropdown-item> -->
              <!-- <el-dropdown-item>
                <el-button @click="get_BranchFactoryList(scope.row)" type="text"
                  v-permission="['shezhi_fenchang']">设置分厂</el-button>
              </el-dropdown-item> -->
              <!-- <el-dropdown-item>
                <el-button @click="push_prders_product(scope.row)" type="text"
                  v-permission="['shezhi_jiage']">设置价格</el-button>
              </el-dropdown-item> -->
              <el-dropdown-item>
                <el-button @click="push_biaoji(scope.row)" type="text"
                  >添加标记</el-button
                >
              </el-dropdown-item>
              <el-dropdown-item>
                <el-popconfirm
                  v-permission="['dingdan_shanchu']"
                  confirm-button-text="确定"
                  cancel-button-text="取消"
                  icon="el-icon-info"
                  icon-color="red"
                  title="确定删除此订单吗？"
                  @confirm="del_Order(scope.row.id)"
                >
                  <el-button slot="reference" size="small" type="text"
                    >删除</el-button
                  >
                </el-popconfirm>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @current-change="handleCurrentChange"
        background
        @prev-click="prev"
        @next-click="next"
        :current-page.sync="pagination.page"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>

    <el-dialog
      title="订单详情"
      :visible.sync="isjietu"
      width="53%"
      :close-on-click-modal="false"
    >
      <div id="printArea" ref="printArea">
        <table style="width: 100%; border-collapse: collapse">
          <tr
            style="
              display: grid;
              grid-template-columns: 1fr;
              place-items: center;
              justify-content: center;
              align-items: center;
            "
          >
            <td>
              <span>订单号</span>
              <span>{{ ruleForm.order_number }}</span>
            </td>

            <td>
              <span>流水号</span>
              <span>{{ ruleForm.serial_number }}</span>
            </td>

            <td>
              <span>下单日期</span>
              <span>{{ ruleForm.order_date }}</span>
            </td>

            <td>
              <span>交货日期</span>
              <span>{{ ruleForm.delivery_date }}</span>
            </td>
            <td>
              <span>客户</span>
              <span>{{ ruleForm.customer_name }}</span>
            </td>
            <td>
              <span>业务员</span>
              <span>{{ ruleForm.account_executive }}</span>
            </td>

            <td>
              <span>产品</span>
              <span>{{ ruleForm.product_name }}</span>
            </td>
            <td>
              <span>型号</span>
              <span>{{ ruleForm.model_number }}</span>
            </td>

            <td>
              <span>颜色</span>
              <span>{{ ruleForm.color }}</span>
            </td>

            <td v-if="forEachs('specification_id')">
              <span>规格</span>
              <span>{{ ruleForm.specification }}</span>
            </td>

            <td v-if="forEachs('direction')">
              <span>方向</span>
              <span>{{ ruleForm.direction }}</span>
            </td>
            <td v-if="forEachs('is_replenishment')">
              <span>是否补录</span>
              <span>{{ ruleForm.is_replenishment == 1 ? "是" : "否" }}</span>
            </td>
            <td v-if="forEachs('emergency_procedure')">
              <span>紧急程度</span>
              <span>{{
                ruleForm.emergency_procedure == 1
                  ? "普通"
                  : ruleForm.emergency_procedure == 2
                  ? "紧急"
                  : "十万火急"
              }}</span>
            </td>
            <td v-if="forEachs('is_stock_up')">
              <span>是否备货</span>
              <span>{{ ruleForm.is_stock_up == 1 ? "是" : "否" }}</span>
            </td>
            <td v-if="ruleForm.is_replenishment == 1 && forEachs('num')">
              <span>件数</span>
              <span>{{ ruleForm.num }}</span>
            </td>
            <td
              v-if="ruleForm.is_replenishment == 1 && forEachs('warehouse_id')"
            >
              <span>仓库</span>
              <span>{{ ruleForm.warehouse }}</span>
            </td>
            <td
              v-if="ruleForm.is_replenishment == 1 && forEachs('warehouse_id')"
            >
              <span>货架</span>
              <span>{{ ruleForm.goods_shelf }}</span>
            </td>
            <td v-if="forEachs('receivables')">
              <span>应收款</span>
              <span>{{ ruleForm.receivables }}</span>
            </td>
            <td v-if="forEachs('received')">
              <span>已收款</span>
              <span>{{ ruleForm.received }}</span>
            </td>
            <td v-for="(item, index) in FieldList_new" :key="index">
              <span>
                {{ item.name }}
              </span>
              <span>{{ item.default_value }}</span>
            </td>
          </tr>
          <tr>
            <td v-if="forEachs('remark')" style="width: 100%">
              <span style="width: 150px">备注</span>
              <span style="flex: 1">{{ ruleForm.remark }}</span>
            </td>
          </tr>
        </table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button
          @click="isjietu = false"
          type="primary"
          size="small"
          style="margin-right: 10px"
          >取 消</el-button
        >
        <el-popconfirm
          confirm-button-text="确定"
          cancel-button-text="取消"
          title="是否确认订单信息？"
          icon="el-icon-info"
          icon-color="red"
          @confirm="submitadd"
        >
          <el-button slot="reference" type="primary" size="small">
            确认</el-button
          >
        </el-popconfirm>
      </span>
    </el-dialog>

    <el-dialog
      title="生产订单领取及完成情况表"
      :visible.sync="isProducts"
      width="50%"
      :close-on-click-modal="false"
      @close="isProducts_close"
    >
      <el-table :data="moreList" style="width: 100%" border>
        <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
        <el-table-column prop="serial_number" label="工种" width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.job_type.job_type }}</span>
          </template>
        </el-table-column>
        <el-table-column label="领单人" width="120">
          <template slot-scope="scope">
            <span
              v-if="scope.row.is_epiboly == 1 || scope.row.employee"
              :style="{ color: scope.row.is_epiboly == 1 ? 'red' : '' }"
              >{{
                scope.row.is_epiboly == 1
                  ? "外包"
                  : scope.row.employee.employee_name
              }}</span
            >
          </template>
        </el-table-column>
        <el-table-column label="指派日期" width="170">
          <template slot-scope="scope">
            <span v-if="scope.row.is_epiboly == 1 || scope.row.employee">{{
              scope.row.is_epiboly == 1
                ? scope.row.epiboly_time
                : scope.row.appoint_time
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="draw_time" label="领单日期"> </el-table-column>
        <el-table-column prop="submit_time" label="完成日期"> </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <!-- <el-button @click="add_dayinpush_plus" type="primary" size="small">添加到打印列表</el-button> -->
        <el-button @click="isProducts = false" type="primary" size="small"
          >关闭</el-button
        >
      </span>
    </el-dialog>

    <bigimg
      :imgurl="bigurl"
      :product="bigproduct"
      :model_number="bigmodel_number"
      ref="img_big"
    ></bigimg>

    <el-dialog
      title="打印标签件数"
      :visible.sync="isbiaoqian"
      width="30%"
      @close="close_dialog_2"
    >
      <div>
        <el-row style="display: flex; align-items: center">
          <el-col :span="5">标签标题 </el-col>
          <el-col :span="20">
            <el-input
              v-model="biaoqian_name"
              placeholder="请输入标签标题"
              style="width: 100%; text-align: left"
            ></el-input>
          </el-col>
        </el-row>
        <el-row style="display: flex; align-items: center; margin-top: 10px">
          <el-col :span="5"> 件数 </el-col>
          <el-col :span="20">
            <el-input-number
              v-model="biaoqian_num"
              label="请输入件数"
              style="width: 100%; text-align: left"
            ></el-input-number>
          </el-col>
        </el-row>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isbiaoqian = false" type="primary" size="small"
          >取 消</el-button
        >
        <el-button @click="prints_box" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="订单预览"
      :visible.sync="isyulan_ruleForm"
      width="80%"
      @close="close_ruleFormlist"
    >
      <el-table :data="ruleFormlist">
        <el-table-column prop="received" label="产品类型" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.pid_name }}</span>
              <span
                :class="[
                  pid_change(scope.row.pid_name) == true ? 'none' : 'red',
                ]"
                >请检查产品类型是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="模型" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.modelid_name }}</span>
              <span
                :class="[
                  ModelList_change_true(
                    scope.row.pid_name,
                    scope.row.modelid_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查模型是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="是否补录" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{
                scope.row.is_replenishment_name == "是" ? "是" : "否"
              }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="流水号" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.serial_number }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="订单号" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.order_number }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="下单日期" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.order_date }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="交货日期" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.delivery_date }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="客户" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.customer_id_name }}</span>
              <span
                :class="[
                  Customer_changes(scope.row.customer_id_name) == true
                    ? 'none'
                    : 'red',
                ]"
                >请检查客户是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="业务员" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.account_executive_id_name }}</span>
              <span
                :class="[
                  account_executive_changes(
                    scope.row.account_executive_id_name
                  ) == true
                    ? 'none'
                    : 'red',
                ]"
                >请检查业务员是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="紧急程度" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{
                scope.row.emergency_procedure_name == 1
                  ? "普通"
                  : scope.row.emergency_procedure == 2
                  ? "紧急"
                  : "十万火急"
              }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="是否备货" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.is_stock_up_name == 1 ? "是" : "否" }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="订单数量" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.num }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="应收款" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.receivables }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="已收款" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.received }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="discount" label="折扣" width="180">
        </el-table-column>
        <el-table-column label="备注" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.remark }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="产品" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.product_id_name }}</span>

              <span
                :class="[
                  productList_changes(scope.row.product_id) == true
                    ? 'none'
                    : 'red',
                ]"
                >请检查产品是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="型号" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.model_number_id_name }}</span>
              <!-- <span
                :class="[
                  model_number_changes(
                    scope.row.product_id_name,
                    scope.row.model_number_id_name
                  ) == true
                    ? 'none'
                    : 'red',
                ]"
                >请检查型号是否存在</span
              > -->
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="颜色" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.color_id_name }}</span>
              <span
                :class="[
                  color_changes_true(
                    scope.row.product_id,
                    scope.row.color_id_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查颜色是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="规格" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.specification_id_name }}</span>
              <span
                :class="[
                  SpecificationList_changes_true(
                    scope.row.specification_id_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查规格是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="库存" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="库存(半成品订单)" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="发货仓库" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.warehouse_id_name }}</span>
              <span
                :class="[
                  warehouse_changes_true(scope.row.warehouse_id_name)
                    ? 'none'
                    : 'red',
                ]"
                >请检查仓库是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="是否要床头柜" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.is_chuangtougui_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="床板" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangban.product_id_name }}</span>
              <span
                :class="[
                  product_chuangotugui_true(
                    scope.row.modelid,
                    scope.row.chuangban.product_id_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查此床板是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="received"
          label="是否选择库存（床板）"
          width="180"
        >
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangban.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="床头" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangtou.product_id_name }}</span>
              <span
                :class="[
                  product_chuangotugui_true(
                    scope.row.modelid,
                    scope.row.chuangtou.product_id_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查此床头是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="received"
          label="是否选择库存（床头）"
          width="180"
        >
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangtougui.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="床帮" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangbang.product_id_name }}</span>
              <span
                :class="[
                  product_chuangotugui_true(
                    scope.row.modelid,
                    scope.row.chuangbang.product_id_name
                  )
                    ? 'none'
                    : 'red',
                ]"
                >请检查此床帮是否存在</span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="received"
          label="是否选择库存（床帮）"
          width="180"
        >
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangbang.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="received" label="床头柜" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangtougui.product_id_name }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="received"
          label="是否选择库存（床头柜）"
          width="180"
        >
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangtougui.is_kucun_name }}</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="received" label="数量（床头柜）" width="180">
          <template slot-scope="scope">
            <div class="list_li">
              <span>{{ scope.row.chuangtougui.chuangtougui_num }}</span>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <span slot="footer" class="dialog-footer">
        <el-button @click="isyulan_ruleForm = false" type="primary" size="small"
          >取 消</el-button
        >
        <el-button @click="sub_ruleForm" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="成品价及发货价"
      :visible.sync="si_price"
      width="25%"
      :close-on-click-modal="false"
      @close="isProducts_si_price"
    >
      <el-form label-width="100px" class="demo-ruleForm">
        <el-form-item label="订单号">
          <el-input v-model="product_object.order_number" disabled></el-input>
        </el-form-item>
        <el-form-item label="成品价">
          <el-input-number
            v-model="product_object.product_price"
            :min="1"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="发货价">
          <el-input-number
            v-model="product_object.send_price"
            :min="1"
          ></el-input-number>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="si_price = false" type="primary" size="small"
          >取消</el-button
        >
        <el-button @click="push_si_price" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="是否分厂"
      :visible.sync="is_fenchang"
      width="25%"
      :close-on-click-modal="false"
      @close="is_fenchang_close"
    >
      <el-form label-width="100px" class="demo-ruleForm">
        <el-form-item label="生产厂家">
          <el-select
            filterable
            clearable
            allow-create
            v-model="fenchang.branch_factory_id"
            placeholder="请选择生产厂家"
            style="width: 100%"
          >
            <el-option
              v-for="(item, index) in FactoryList"
              :key="index"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="is_fenchang = false" type="primary" size="small"
          >取消</el-button
        >
        <el-button @click="switch_change" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="设置已收款"
      :visible.sync="is_kaun"
      width="25%"
      :close-on-click-modal="false"
      @close="is_fenchang_close"
    >
      <el-form label-width="100px" class="demo-ruleForm">
        <el-form-item label="已收款">
          <el-input v-model="received"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="is_kaun = false" type="primary" size="small"
          >取消</el-button
        >
        <el-button @click="change_received" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <el-dialog
      title="设置标记"
      :visible.sync="is_biaoji"
      width="25%"
      :close-on-click-modal="false"
      @close="is_fenchang_close"
    >
      <el-form label-width="100px" class="demo-ruleForm">
        <el-form-item label="标记旗">
          <el-radio-group
            v-model="biaoji.order_color"
            :disabled="disableds"
            class="biaoji_radio"
          >
            <el-radio label="#FF0000"
              ><i class="el-icon-s-flag" style="color: #ff0000"></i
            ></el-radio>
            <el-radio label="#FFA500"
              ><i class="el-icon-s-flag" style="color: #ffa500"></i
            ></el-radio>
            <el-radio label="#000000"
              ><i class="el-icon-s-flag" style="color: #000000"></i
            ></el-radio>
            <el-radio label="#008000"
              ><i class="el-icon-s-flag" style="color: #008000"></i
            ></el-radio>
            <el-radio label="#00FFFF"
              ><i class="el-icon-s-flag" style="color: #00ffff"></i
            ></el-radio>
            <el-radio label="#0000FF"
              ><i class="el-icon-s-flag" style="color: #0000ff"></i
            ></el-radio>
            <el-radio label="#800080"
              ><i class="el-icon-s-flag" style="color: #800080"></i
            ></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="biaoji.other_remark"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="is_biaoji = false" type="primary" size="small"
          >取消</el-button
        >
        <el-button @click="set_OrderRemark(0)" type="primary" size="small"
          >清除</el-button
        >
        <el-button @click="set_OrderRemark(1)" type="primary" size="small"
          >确定</el-button
        >
      </span>
    </el-dialog>

    <!-- 新增订单 -->
    <addorder ref="add_orders" @get_list="getlist" />
  </div>
</template>

<script>
import {
  addOrderPrint,
  getColorList,
  getOrderList,
  createOrder,
  getProductList,
  getModelNumberList,
  getCustomerList,
  assignOrderChild,
  epibolyOrderChild,
  getUserListByJobTypeId,
  getOrderChildListByOrderId,
  getWarehouseList,
  getOrderAuditList,
  downloadcode,
  getOrderFieldLogList,
  automaticGenerationSerialNumber,
  setOrderFieldLogList,
  getSpecificationList,
  delOrder,
  getProductColorList,
  automaticGenerationOrderNumber,
  drawOrderChildByEmployeeCardNumnber,
  createSpecification,
  createColor,
  getProductFieldList,
  getModelList,
  updateFinishProductNum,
  getModelNumberListByProduct,
  getProductInfoByModelNumberId,
  importOrder,
  setOrderByPrice,
  setOrderByBranchFactory,
  getBranchFactoryList,
  setOrderRemark,
  getOrderDetail,
} from "@/api/product/index";
import html2canvas from "html2canvas";
import { getYeWuYuanList } from "@/api/user";
import bigimg from "@/components/bigimg";
import addorder from "@/components/Addorder";
import { myMixin } from "@/utils/mixin";
import { read, utils } from "xlsx";
export default {
  inject: ["refresh"],
  mixins: [myMixin],
  components: {
    bigimg,
    addorder,
  },
  data() {
    return {
      isadd_show: false,
      is_biaoji: false,
      is_kaun: false,
      received: "",
      si_price: false,
      headers: { "Content-Type": "multipart/form-data" },
      wanchengs_list: [],
      isyulan_ruleForm: false,
      ruleFormlist: [],
      isbiaoqian: false,
      biaoqian_num: "",
      biaoqian_name: "",
      type: 1,
      ModelList: [],
      isshow: true,
      isjietu: false,
      logistics_statuslist: [
        {
          status: 1,
          lable: "待发货",
        },
        {
          status: 2,
          lable: "未发货",
        },
        {
          status: 3,
          lable: "已发货",
        },
      ],
      directionList: [
        {
          name: "左",
        },
        {
          name: "右",
        },
        {
          name: "无",
        },
      ],
      loading: true,
      SpecificationList_s: [],
      ModelNumberList_s: [],
      ColorList_s: [],
      disableds: false,
      disableds_product: false,
      bigurl: "",
      bigproduct: "",
      bigmodel_number: "",
      permissions_arr: [],
      options_order: [],
      uploadImgUrl: this.$global.imgQianJui,
      permission: "",
      permissions: "",
      permissions_s: [],
      props: {
        multiple: true,
      },
      checkAll: false,
      isIndeterminate: false,
      order_data: [],
      ModelNumberLists: [],
      isset: false,
      moreList: [],
      moreLists: {},
      isProducts: false,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        },
      },
      formatterTime(row, column) {
        let data = row[column.property];
        return /\d{4}-\d{1,2}-\d{1,2}/g.exec(data);
      },
      title: "",
      isProduct: false,
      dataList: [],
      ser: {
        serial_number: "",
        customer_name: "",
        model_number_id: "",
        order_number: "",
        customer_id: "",
        product_id: "",
        order_date: "",
        is_replenishment: "",
        is_stock_up: "",
        start_time: "",
        end_time: "",
        branch_factory_id: "",
      },
      ruleForm: {
        modelid: "",
        num: "",
        warehouse_id: "",
        goods_shelf_id: "",
        batch_number: "",
        serial_number: "",
        order_number: "",
        order_date: "",
        delivery_date: "",
        account_executive_id: "",
        product_id: "",
        model_number_id: "",
        color_id: "",
        size: "",
        specification_id: "",
        direction: "",
        customer_id: "",
        received: "",
        emergency_procedure: "1",
        is_replenishment: "2",
        is_stock_up: "2",
        receivables: "",
        remark: "",
        id: "",
      },
      rules: {
        num: [{ required: true, message: "请输入数量", trigger: "blur" }],
        warehouse_id: [
          { required: true, message: "请选择仓库", trigger: "blur" },
        ],
        goods_shelf_id: [
          { required: true, message: "请选择货架", trigger: "blur" },
        ],
        batch_number: [
          {
            required: true,
            message: "请输入生产批号",
            trigger: "blur",
          },
        ],
        specification_id: [
          {
            required: true,
            message: "请选择规格",
            trigger: "blur",
          },
        ],
        serial_number: [
          {
            required: true,
            message: "请输入流水号",
            trigger: "blur",
          },
        ],
        order_number: [
          {
            required: true,
            message: "请输入订单号",
            trigger: "blur",
          },
        ],
        order_date: [
          {
            required: true,
            message: "请选择下单日期",
            trigger: "blur",
          },
        ],
        delivery_date: [
          {
            required: true,
            message: "请选择交货日期",
            trigger: "blur",
          },
        ],
        account_executive_id: [
          {
            required: true,
            message: "请选择员工",
            trigger: "blur",
          },
        ],
        product_id: [
          {
            required: true,
            message: "请选择产品",
            trigger: "blur",
          },
        ],
        model_number_id: [
          {
            required: true,
            message: "请选择型号",
            trigger: "blur",
          },
        ],
        color_id: [
          {
            required: true,
            message: "请选择颜色",
            trigger: "blur",
          },
        ],
        size: [
          {
            required: true,
            message: "请选择规格",
            trigger: "blur",
          },
        ],
        direction: [
          {
            required: true,
            message: "请输入产品方向",
            trigger: "blur",
          },
        ],
        customer_id: [
          {
            required: true,
            message: "请选择客户",
            trigger: "blur",
          },
        ],
        emergency_procedure: [
          {
            required: true,
            message: "请选择紧急程度",
            trigger: "blur",
          },
        ],
        is_replenishment: [
          {
            required: true,
            message: "是否补货",
            trigger: "blur",
          },
        ],
        received: [
          {
            required: true,
            message: "请输入应收款",
            trigger: "blur",
          },
        ],
        receivables: [
          {
            required: true,
            message: "请输入已收款",
            trigger: "blur",
          },
        ],
        is_stock_up: [
          {
            required: true,
            message: "是否备货",
            trigger: "blur",
          },
        ],
        receivables: [
          {
            required: true,
            message: "请输入应收款金额",
            trigger: "blur",
          },
        ],
      },
      pagination: {
        per_page: 10,
        page: 1,
      },
      total: 0,
      productList: [],
      EmployeeList: [],
      ModelNumberList: [],
      ColorList: [],
      SpecificationList: [],
      CustomerList: [],
      // 指派提交数据
      push_prder: {
        child_order_id: "",
        employee_user_id: "",
      },
      push_more: {},
      pushCustomerList: [], //指定工种员工列表
      // 外包提交
      modelid: "",
      cangkulist: [],
      huojialist: [],
      AuditList: [],
      sort_types: false,
      order_ids: "",
      dc_order_ids: [],
      FieldList: [],
      FieldList_new: [],
      productList_mx: [],
      dayinlist: [],
      dayinlist_biaoqian: [],
      fileList: [],
      tableData: [],
      tableHead: [],
      ModelLists: [],
      ModelNumberList_li: [],
      model_number_id_s: "",
      ruleFormlists: [],
      push_prders: {
        employee_user_id: "", //员工
        job_type_id: "", //工种
        order_id: "", //订单id
        order_second_id: "",
      },

      is_morezhipai: false,
      job_type_list: [], //当前订单工种列表
      product_object: {
        order_number: "",
        id: "",
        product_price: 0,
        send_price: 0,
      },
      fenchang: {
        branch_factory_id: "",
        id: "",
      },
      is_fenchang: false,
      FactoryList: [],
      xiu_id: "",
      biaoji: {
        id: "",
        order_color: "",
        other_remark: "",
      },
      selectedRows: [],
      currentPageData: [],
    };
  },
  created() {
    this.get_OrderFieldLogList();
  },
  mounted() {
    this.getlist();
    this.getproduct();
    this.getEmpl();
    this.getModel();
    this.getCustomer();
    this.getcangku();
    this.get_OrderAuditList();
    this.get_BranchFactoryList_s();
    localStorage.setItem("dayinlist", []);
  },

  methods: {

    uploadUrl() {
      return `${process.env.VUE_APP_API_ROOT}/gw-console/v1/category-template/batch-import/import`;
    },
    set_OrderRemark(type) {
      if (type) {
        setOrderRemark(this.biaoji).then((res) => {
          if (res.code == 200) {
            this.$message({
              message: "标记成功",
              type: "success",
            });
            this.is_biaoji = false;
            this.getlist();
            this.biaoji = {
              id: "",
              order_color: "",
              other_remark: "",
            };
          } else {
            this.$message({
              message: res.msg,
              type: "warning",
            });
          }
        });
      } else {
        let obj = {
          id: this.biaoji.id,
          order_color: "",
          other_remark: "",
        };
        setOrderRemark(obj).then((res) => {
          if (res.code == 200) {
            this.$message({
              message: "标记成功",
              type: "success",
            });
            this.is_biaoji = false;
            this.getlist();
            this.biaoji = {
              id: "",
              order_color: "",
              other_remark: "",
            };
          } else {
            this.$message({
              message: res.msg,
              type: "warning",
            });
          }
        });
      }
    },
    push_biaoji(row) {
      this.biaoji.id = row.id;
      this.biaoji.order_color = row.order_color ? row.order_color : "";
      this.biaoji.other_remark = row.other_remark ? row.other_remark : "";
      this.is_biaoji = true;
    },
    get_BranchFactoryList_s() {
      getBranchFactoryList({ is_simple: 1 }).then((res) => {
        if (res.code == 200) {
          this.FactoryList = res.data;
        }
      });
    },
    set_yishoukuan(row) {
      this.xiu_id = row.id;
      this.is_kaun = true;
      this.received = row.received;
    },
    change_received() {
      let obj = {
        id: this.xiu_id,
        parameter: "received",
        value: this.received,
      };
      setOrderByBranchFactory(obj).then((res) => {
        if (res.code == 200) {
          this.$message.success("提交成功");
          this.is_kaun = false;
          this.getlist();
        }
      });
    },
    is_fenchang_close() {
      this.is_fenchang = false;
      this.fenchang = {
        branch_factory_id: "",
        id: "",
      };
    },

    get_BranchFactoryList(row) {
      this.fenchang.id = row.id;
      getBranchFactoryList({ is_simple: 1 }).then((res) => {
        if (res.code == 200) {
          this.FactoryList = res.data;
          this.is_fenchang = true;
        }
      });
    },
    switch_change() {
      let obj = {
        id: this.xiu_id,
        parameter: "branch_factory_id",
        value: this.fenchang.branch_factory_id,
      };
      setOrderByBranchFactory(this.fenchang).then((res) => {
        if (res.code == 200) {
          this.$message.success("提交成功");
          this.is_fenchang = false;
          this.getlist();
        }
      });
    },
    isProducts_si_price() {
      this.product_object = {
        order_number: "",
        order_id: "",
        product_price: 0,
        send_price: 0,
      };
    },
    push_prders_product(row) {
      this.product_object.id = row.id;
      this.product_object.order_number = row.order_number;
      this.si_price = true;
    },
    push_si_price() {
      setOrderByPrice(this.product_object).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "提交成功",
            type: "success",
          });
          this.getlist();
          this.si_price = false;
        }
      });
    },
    push_prders_change() {
      this.is_morezhipai = false;
      this.getOrderChild(2);
    },
    //获取指定工种员工列表
    getUser(id) {
      getUserListByJobTypeId({ job_type_id: id }).then((res) => {
        if (res.code == 200) {
          this.pushCustomerList = res.data;
        }
      });
    },
    // 领单详情工种
    job_type_employee_user_1(val) {
      this.push_prders.employee_user_id = "";
      this.job_type_list.forEach((item) => {
        if (val == item.job_type_id) {
          this.push_prder.order_second_id = item.order_second_id;
        }
      });
      this.getOrderChild(2);
      this.getUser(val);
      this.is_morezhipai = false;
    },
    add_dayinpush_plus() {
      let ids = [];
      this.wanchengs_list.forEach((item) => {
        if (item.draw_time || item.is_epiboly == 1) {
          ids.push(item.id);
        } else {
          this.$message.error("请选择已领取或外包的订单~");
        }
      });
      this.add_dayinpush_plus_s(ids);
    },
    handleSelectionChang(val) {
      this.wanchengs_list = val;
    },
    add_dayinpush_plus_s(ids) {
      let obj = {
        order_id: this.order_id,
        order_child_ids: ids,
      };
      addOrderPrint(obj).then((res) => {
        if (res.code == 200) {
          this.$message.success("添加成功");
        }
      });
    },
    // 外
    set_products(row) {
      // this.moreLists = row;
      this.push_prders.order_id = row.order_id;
      this.order_id = row.order_id;
      this.push_prders.order_second_id = row.id;
      this.job_type_list = row.job_type_list;
      this.isProducts = true;
      this.getOrderChild();
    },
    async zi_product_change(val) {
      var id;
      var arry = [];
      await getModelList().then((res) => {
        if (res.code == 200) {
          arry = res.data;
          arry.forEach((item) => {
            if (item.modelname == val) {
              id = item.modelid;
            }
          });
        }
      });
      return id;
    },
    async sub_ruleForm() {
      let span_list = document.getElementsByClassName("list_li");
      span_list.forEach((item) => {
        item.children.forEach((ite) => {
          if (ite.className == "red") {
            this.$message.error("请核对订单信息！");
            return false;
          }
        });
      });
      await createOrder({ order_data: this.ruleFormlists }).then((res) => {
        if (res.code == 200) {
          this.isyulan_ruleForm = false;
          this.$message.success("提交成功");
        }
      });
    },
    async warehouse_changes_true(val) {
      var list = [];
      var id;
      await getWarehouseList({ warehouse_type_id: 1 }).then((res) => {
        if (res.code == 200) {
          list = res.data.data;
          list.forEach((item) => {
            if (val == item.warehouse_name) {
              id = item.id;
            }
          });
        }
      });
      return id;
    },
    // 子产品校验及赋值
    async product_chuangotugui_true(modelids, val) {
      var id;
      var list = [];
      await getProductList({ is_dropdown: 1, modelid: modelids }).then(
        (res) => {
          if (res.code == 200) {
            list = res.data;
            list.forEach((item) => {
              if (val == item.product_name) {
                id = item.id;
              }
            });
          }
        }
      );
      return id;
    },
    // 规格赋值
    async SpecificationList_changes_true(val) {
      var SpecificationList = [];
      var id;
      await getSpecificationList().then((res) => {
        if (res.code == 200) {
          SpecificationList = res.data.data;
          SpecificationList.forEach((item) => {
            if (val == item.specification) {
              id = item.id;
            }
          });
        }
      });
      return id;
    },
    // 产品-颜色赋值
    async color_changes_true(product, color) {
      var id;
      var ColorList = [];
      await getProductColorList({ product_id: product }).then((res) => {
        if (res.code == 200) {
          ColorList = res.data;
          ColorList.forEach((item) => {
            if (color == item.color) {
              id = item.id;
            }
          });
        }
      });
      return id;
    },
    // 订单预览关闭
    close_ruleFormlist() {},
    //校验pid
    pid_change(val) {
      if (val != "成品" && val != "半成品") {
        return false;
      } else {
        return true;
      }
    },
    //赋值pid
    pid_change_true(val) {
      if (val == "成品") {
        return 1;
      } else {
        return 2;
      }
    },
    //赋值产品类型
    async ModelList_change_true(type, val) {
      var ModelList = [];
      var types;
      var id;
      if (type == "成品") {
        types = 1;
      } else {
        types = 2;
      }
      let obj = {
        is_dropdown: 1,
        type: types,
      };
      await getModelList(obj).then((res) => {
        if (res.code == 200) {
          ModelList = res.data;
        }
      });
      var model = [];
      ModelList.forEach((item) => {
        model.push(item.modelname);
      });
      let istrue;
      if (model.includes(val)) {
        istrue = true;
      } else {
        istrue = false;
        return false;
      }
      if (istrue) {
        ModelList.forEach((item) => {
          if (item.modelname == val) {
            id = item.modelid;
          }
        });
      }
      return id;
    },
    //校验客户
    Customer_changes(val) {
      let arry = [];
      this.CustomerList.forEach((item) => {
        arry.push(item.customer_name);
      });
      if (arry.includes(val)) {
        return true;
      } else {
        return false;
      }
    },
    //赋值客户
    Customer_change_true(val) {
      var arry = [];
      var id;
      this.CustomerList.forEach((item) => {
        arry.push(item.customer_name);
      });
      let istrue;
      if (arry.includes(val)) {
        istrue = true;
      } else {
        istrue = false;
      }
      if (istrue) {
        this.CustomerList.forEach((item) => {
          if (val == item.customer_name) {
            id = item.id;
          }
        });
      }
      return id;
    },
    //校验业务员
    account_executive_changes(val) {
      let arry = [];
      this.EmployeeList.forEach((item) => {
        arry.push(item.company_name);
      });
      if (arry.includes(val)) {
        return true;
      } else {
        return false;
      }
    },
    //赋值业务员
    account_executive_change_true(val) {
      var arry = [];
      var id;
      this.EmployeeList.forEach((item) => {
        arry.push(item.company_name);
      });
      let istrue;
      if (arry.includes(val)) {
        istrue = true;
      } else {
        istrue = false;
      }
      if (istrue) {
        this.EmployeeList.forEach((item) => {
          if (val == item.company_name) {
            id = item.id;
          }
        });
      }
      return id;
    },
    //校验产品
    productList_changes(val) {
      let arry = [];
      this.productList.forEach((item) => {
        arry.push(item.product_name);
      });
      if (arry.includes(val)) {
        return true;
      } else {
        return false;
      }
    },
    //赋值产品
    productList_changes_true(val) {
      var arry = [];
      var id;
      this.productList.forEach((item) => {
        arry.push(item.product_name);
      });
      var istrue;
      if (arry.includes(val)) {
        istrue = true;
      } else {
        istrue = false;
      }
      if (istrue) {
        this.productList.forEach((item) => {
          if (val == item.product_name) {
            id = item.id;
          }
        });
      }
      return id;
    },
    //校验型号
    model_number_changes(product, model_number) {
      var arry = [];

      let id = this.productList_changes_true(product);
      getModelNumberListByProduct({ product_id: id }).then((res) => {
        if (res.code == 200) {
          this.ModelNumberList_li = res.data;
        }
      });

      this.ModelNumberList_li.forEach((item) => {
        arry.push(item.model_number);
      });

      if (arry.includes(model_number)) {
        return true;
      } else {
        return false;
      }
    },
    //赋值型号
    async model_number_changes_true(product, model_number) {
      let id = this.productList_changes_true(product);
      let result = await getModelNumberListByProduct({ product_id: id }).then(
        (res) => {
          var model_number_id_s;
          if (res.code == 200) {
            var ModelNumberList_li = [];
            var arry = [];
            ModelNumberList_li = res.data;
            ModelNumberList_li.forEach((item) => {
              arry.push(item.model_number);
            });
            var istrue;
            if (arry.includes(model_number)) {
              istrue = true;
            } else {
              istrue = false;
            }
            if (istrue) {
              ModelNumberList_li.forEach((item) => {
                if (model_number == item.model_number) {
                  model_number_id_s = item.id;
                }
              });
            }
          }
          return model_number_id_s;
        }
      );
      return result;
    },
    uploadUrl() {
      return `${process.env.VUE_APP_API_ROOT}/gw-console/v1/category-template/batch-import/import`;
    },
    progress(event, file, fileList) {},
    handleExceed(file, fileList) {
      let files = [];
      files.push(file);
      this.readExcel(files);
    },
    readExcel(file) {
      let fd = new FormData();
      file.forEach((element) => {
        fd.append("uploadFile", element.raw); //这里是raw,不是row 仔细仔细！
      });

      importOrder(fd).then((response) => {
        //addFileLoad是调后台的方法
        if (response.code == 200) {
          this.$message.success(`上传成功${response.data.success_num}条`);
          this.dataList = [];
          this.getlist();
          this.fileList = [];
        } else {
          this.$message({
            type: "error",
            message: "请勾选数据",
          });
        }
      });
      // const fileReader = new FileReader();
      // fileReader.onload = (ev) => {
      //   try {
      //     const data = ev.target.result;
      //     const workbook = read(data, { type: "binary" });
      //     const params = [];
      //     // 取对应表生成json表格内容
      //     workbook.SheetNames.forEach((item) => {
      //       this.tableData.push(utils.sheet_to_json(workbook.Sheets[item]));
      //     });
      //     // 该算法仅针对表头无合并的情况
      //     if (this.tableData.length > 0) {
      //       // 获取excel中第一个表格数据tableData[0][0]，并且将表头提取出来
      //       for (const key in this.tableData[0][0]) {
      //         this.tableHead.push(key);
      //       }
      //     }
      //     // 重写数据
      //   } catch (e) {
      //    // console.log("error:" + e);
      //     return false;
      //   }
      // };
      // fileReader.readAsBinaryString(file[0].raw);
      //// console.log(this.tableHead);
      //// console.log(this.tableData);
    },
    close_dialog_2() {},
    handleSelectionChange(val) {
      this.dc_order_ids = [];
      this.dayinlist = val;
      this.dayinlist_biaoqian = val;

      val.forEach((item) => {
        this.dc_order_ids.push(item.id);
      });
    },
    prin() {
      if (this.dayinlist.length > 0) {
        const routerurl = this.$router.resolve({
          name: "orderdayin",
          path: "/dayin",
          query: {
            data: JSON.stringify(this.dayinlist),
          },
        });
        window.open(routerurl.href, "_blank");
      } else {
        this.$message({
          type: "error",
          message: "请勾选数据",
        });
        return false;
      }
    },

    push_num_jianshus(id, nums) {
      const routerurl = this.$router.resolve({
        name: "biaoqian",
        path: "/biaoqian",
        query: {
          data: JSON.stringify(this.dayinlist_biaoqian),
          num: nums,
        },
      });
      window.open(routerurl.href, "_blank");
    },
    //打印标签
    prints_box() {
      this.push_num_jianshus(this.dayinlist_biaoqian[0].id, this.biaoqian_num);
    },
    prints() {
      if (this.dayinlist_biaoqian.length) {
        this.biaoqian_num = this.dayinlist_biaoqian[0].num;
        // this.dayinlist_biaoqian[0].biaoqian_name = "";
        this.isbiaoqian = true;
        // const routerurl = this.$router.resolve({
        //   name: "biaoqian",
        //   path: "/biaoqian",
        //   query: {
        //     data: JSON.stringify(this.dayinlist_biaoqian),
        //   },
        // });
        // window.open(routerurl.href, "_blank");
        // this.prints_box()
      } else {
        if (this.dayinlist_biaoqian.length == 0) {
          this.$message({
            type: "error",
            message: "请勾选数据",
          });
          return false;
        }
      }
    },
    type_change(val) {
      this.ruleForm.modelid = "";
      this.get_ModelList(val);
    },
    //产品列表
    getproduct_mx(val) {
      getProductList({ is_dropdown: 1, modelid: val }).then((res) => {
        if (res.code == 200) {
          this.productList_mx = res.data;
        }
      });
    },
    modelid_change(val) {
      this.getproduct_mx(val);
      this.get_ProductFieldList(val);
    },
    add_color() {
      this.$refs.add_orders.inits("add_order");
      // 业务员
    },
    get_ModelList() {
      let obj = {
        is_dropdown: 1,
        type: this.type,
      };
      getModelList(obj).then((res) => {
        if (res.code == 200) {
          this.ModelList = res.data;
        }
      });
    },
    push_name(val) {
      for (var i = 0; i < this.FieldList_new.length; i++) {
        if (
          val == this.FieldList_new[i].field &&
          this.FieldList_new[i].show == "1"
        ) {
          return this.FieldList_new[i].name;
        }
      }
    },
    // 指定查询
    search(type) {
      if (type == 0) {
        this.pagination.per_page = 10;
        this.pagination.page = 1;
      }
      // if(this.ser.product_id==''){
      //   this.$message.error("请选择产品");
      //   return false;
      // }
      getOrderList({ ...this.ser, ...this.pagination }).then((res) => {
        if (res.code == 200) {
          // this.get_ProductFieldLists(this.ser.product_id);
          this.dataList = res.data.data;
          this.total = res.data.total;
        }
      });
    },
    get_ProductFieldLists(val) {
      getProductFieldList({ product_id: val }).then((res) => {
        if (res.code == 200) {
          this.FieldList = res.data;
          this.FieldList_new = [];
          this.FieldList.forEach((item) => {
            if (item.is_default == 2) {
              this.FieldList_new.push(item);
            }
          });
        }
      });
    },
    select_goods_shelf(val) {
      this.huojialist.forEach((item) => {
        if (val == item.id) {
          this.$set(this.ruleForm, "goods_shelf", item.goods_shelf);
        }
      });
    },
    direction_change(val) {
      this.directionList.forEach((item) => {
        if (val == item.id) {
          this.$set(this.ruleForm, "direction", item.name);
        }
      });
    },
    account_executive_change(val) {
      this.EmployeeList.forEach((item) => {
        if (val == item.id) {
          this.$set(this.ruleForm, "account_executive", item.company_name);
        }
      });
    },
    customer_change(val) {
      this.CustomerList.forEach((item) => {
        if (val == item.id) {
          this.$set(this.ruleForm, "customer_name", item.customer_name);
        }
      });
    },

    handleExport() {
      let htmlDom = document.getElementById("printArea"); // 你要截图的元素  可直接是img
      var FileSaver = require("file-saver");
      this.$nextTick(function () {
        html2canvas(htmlDom, {
          scale: 1,
          // x: htmlDom.offsetLeft, //传入x和y长度，拒绝空白图片
          // y: htmlDom.offsetTop,
          x: 0, //传入x和y长度，拒绝空白图片
          y: 0,
          allowTaint: false, //允许污染
          taintTest: true, //在渲染前测试图片
          useCORS: true, //使用跨域(当allowTaint为true时这段代码没什么用)
          background: "#fff",
        }).then((canvas) => {
          // getBase64Image（imgurl）
          if (navigator.msSaveBlob) {
            navigator.msSaveBlob(canvas.msToBlob(), "demo.png");
          } else {
            canvas.toBlob(function (blob) {
              FileSaver.saveAs(blob, "demo.png");
            });
          }
        });
      });
    },
    required(val) {
      for (let i = 0; i < this.FieldList.length; i++) {
        if (this.FieldList[i].field == val && this.FieldList[i].required == 1) {
          return this.FieldList[i].field;
        }
      }
    },
    forEachs(val) {
      for (let i = 0; i < this.FieldList.length; i++) {
        if (this.FieldList[i].field == val && this.FieldList[i].show == 1) {
          return true;
        }
      }
    },
    product_id_change_1(val) {
      this.ModelNumberList = [];
      this.ColorList = [];
      this.SpecificationList = [];
      this.ruleForm.model_number_id = "";
      this.ruleForm.color_id = "";
      this.ser.model_number_id = "";
      this.ruleForm.specification_id = "";
      this.get_producModel(val);
      this.get_produccolor(val);
      this.FieldList_new = FieldList_new;
      this.automatic_GenerationSerialNumber();
      this.auto_maticGenerationOrderNumber();
      this.produc_number_id = val;
      this.ruleForm.product_id = val;
      this.productList.forEach((item) => {
        if (val == item.id) {
          this.$set(this.ruleForm, "product_name", item.product_name);
        }
      });
    },
    get_ProductFieldList(val) {
      getProductFieldList({ modelid: val }).then((res) => {
        if (res.code == 200) {
          this.FieldList = res.data;
          let FieldList_new = [];
          this.FieldList.forEach((item) => {
            if (item.is_default == 2) {
              FieldList_new.push(item);
              this.$set(this.ruleForm, item.field, item.default_value);
            }
          });
        }
      });
    },
    yanse_change(val) {
      var list = [];
      for (let i = 0; i < this.ColorList.length; i++) {
        list.push(this.ColorList[i].id);
        if (val == this.ColorList.id) {
          this.$set(this.ruleForm, "color", this.ColorList[i].color);
        }
      }
      if (!list.includes(val)) {
        this.create_Color(val);
      }
    },
    create_Color(val) {
      let lists = [];
      let list = [];
      list.push(val);
      lists.push(this.ruleForm.product_id);
      let obj = {
        product_ids: lists,
        color_names: list,
      };
      createColor(obj).then((res) => {
        if (res.code == 200) {
          let lengths = this.ColorList.length;
          this.$set(this.ColorList, lengths, { id: res.data[0], color: val });
          this.get_produccolor(this.ruleForm.product_id);
          let that = this;
          setTimeout(() => {
            that.ruleForm.color_id = res.data[0];
          }, 500);
        }
      });
    },
    guige_change(val) {
      var list = [];
      for (let i = 0; i < this.SpecificationList.length; i++) {
        list.push(this.SpecificationList[i].id);
        if (val == this.SpecificationList[i].id) {
          this.$set(
            this.ruleForm,
            "specification",
            this.SpecificationList[i].specification
          );
        }
      }
      if (!list.includes(val)) {
        this.update_Specification(val);
      }
    },
    update_Specification(val) {
      let specification_id = [];
      specification_id.push(val);
      let obj = {
        product_id: this.ruleForm.product_id,
        model_number_id: this.ruleForm.model_number_id,
        specification_ids: specification_id,
      };
      createSpecification(obj).then((res) => {
        if (res.code == 200) {
          let lengths = this.SpecificationList.length;
          this.$set(this.SpecificationList, lengths, {
            id: res.data[0],
            specification: val,
          });
          this.model_number_id_changes(
            this.ruleForm.product_id,
            this.ruleForm.model_number_id
          );
        }
        let that = this;
        setTimeout(() => {
          this.ruleForm.specification_id = res.data[0];
        }, 500);
      });
    },
    del_Order(id) {
      delOrder({ id }).then((res) => {
        if (res.code == 200) {
          this.$message.success("操作成功");
          this.isProduct = false;
          this.getlist();
        }
      });
    },
    push_img(row) {
      this.bigurl = row.model_number.file.file_url;
      this.bigproduct = row.product.product_name;
      this.bigmodel_number = row.model_number.model_number;
      this.$refs.img_big.open();
    },
    isProducts_close() {
      this.moreList = [];
      this.order_ids = "";
      this.job_type_list = [];
      this.push_prders = {
        employee_user_id: "", //员工
        job_type_id: "", //工种
        order_id: "", //订单id
        order_second_id: "",
      };
      this.isProducts = false;
    },
    dayin_2(ids) {
      let obj = {
        order_id: this.order_ids,
        order_child_ids: ids,
      };
      addOrderPrint(obj).then((res) => {
        if (res.code == 200) {
          this.$message.success("添加成功");
        }
      });
    },
    dayin(id, ids) {
      let id_s = [];
      id_s.push(ids);
      let obj = {
        order_id: id,
        order_child_ids: id_s,
      };
      addOrderPrint(obj).then((res) => {
        if (res.code == 200) {
          this.$message.success("添加成功");
        }
      });
    },
    // handleSelectionChang(val) {
    //   if (val.length > 0) {
    //     this.multipleSelections = val;
    //     this.order_id = val[0].order_id;
    //     this.multipleSelection = [];
    //     val.forEach((item) => {
    //       let obj = {
    //         user_id: item.employee_user_id,
    //         order_child_id: item.id,
    //       };
    //       this.multipleSelection.push(obj);
    //     });
    //   } else {
    //     this.multipleSelection = [];
    //   }
    // },
    // 设置显示字段
    push_permission() {
      let obj = {
        order_type: 1,
        ids: this.permissions_arr,
      };
      setOrderFieldLogList(obj).then((res) => {
        if (res.code == 200) {
          // console.log(res);
          this.$message.success("设置成功");
          this.getlist();
        }
      });
    },
    dialog_close() {
      this.moreList = [];
    },
    automatic_GenerationSerialNumber() {
      automaticGenerationSerialNumber().then((res) => {
        this.ruleForm.serial_number = res.data;
      });
      0;
      // console.log(this.ruleForm.serial_number);
    },
    get_OrderFieldLogList() {
      getOrderFieldLogList({ order_type: 1 }).then((res) => {
        // console.log(res);
        if (res.code == 200) {
          this.options_order = res.data;
          this.options_order.forEach((item) => {
            if (item.is_show == 1) {
              this.permissions_arr.push(item.id);
            }
          });
        }
        // console.log(this.permissions_arr);
        this.permissions = this.permissions_arr.toString();
        // console.log(this.permissions);
      });
    },
    order_change(val) {
      // console.log(val);
      // console.log();
    },
    getlists(obj) {
      getOrderList(obj).then((res) => {
        if (res.code == 200) {
          this.dataList = res.data.data;
          this.total = res.data.total;
        }
      });
    },
    sort_change(prop) {
      // console.log(prop);
      this.sort_types = !this.sort_types;
      // console.log(this.sort_types);
      let sort_type = "";
      if (this.sort_types == true) {
        sort_type = "desc";
      } else {
        sort_type = "asc";
      }
      let obj = {
        field_name: prop.prop,
        sort_type,
      };
      this.getlists(obj);
    },
    order_data_change(val) {
      this.ser.start_time = val[0];
      this.ser.end_time = val[1];
    },
    // // 型号列表
    getModel() {
      getModelNumberList().then((res) => {
        if (res.code == 200) {
          this.ModelNumberLists = res.data.data;
        }
      });
    },
    product_id_change(val) {
      // console.log(val);
      this.ModelNumberList = [];
      this.ColorList = [];
      this.SpecificationList = [];
      this.ruleForm.model_number_id = "";
      this.ruleForm.color_id = "";
      this.ser.model_number_id = "";
      this.ruleForm.specification_id = "";
      this.get_producModel(val);
      this.get_produccolor(val);
      this.produc_number_id = val;
    },
    set_product(row) {
      getOrderDetail({ id: row.id }).then((res) => {
        if (res.code == 200) {
          this.$refs.add_orders.set_order(res.data[0], "set_order");
        }
      });
    },
    get_produccolor(id) {
      getProductColorList({ product_id: id }).then((res) => {
        if (res.code == 200) {
          this.ColorList = res.data;
        }
      });
    },
    get_producModel(id) {
      getModelNumberList({
        product_id: id,
        field_list: "id,model_number",
        is_dropdown: 1,
        file: 1,
      }).then((res) => {
        if (res.code == 200) {
          this.ModelNumberList = res.data.data;
        }
      });
    },
    model_number_id_changes(id, ids) {
      let obj = {
        product_id: id,
        model_number_id: ids,
      };
      getSpecificationList(obj).then((res) => {
        if (res.code == 200) {
          this.ModelNumberList.forEach((item) => {
            if (ids == item.id) {
              this.$set(this.ruleForm, "model_number", item.model_number);
            }
          });
          this.SpecificationList = res.data.data;
        }
      });
    },
    model_number_id_change(val) {
      let obj = {
        product_id: this.produc_number_id,
        model_number_id: val,
      };
      getSpecificationList(obj).then((res) => {
        if (res.code == 200) {
          this.SpecificationList = res.data.data;
        }
      });
    },
    get_OrderAuditList() {
      getOrderAuditList().then((res) => {
        if (res.code == 200) {
          this.AuditList = res.data.data;
        }
      });
    },
    select_huojiua(val) {
      // console.log(val);
      this.huojialist = [];
      this.cangkulist.forEach((element) => {
        if (val == element.id) {
          this.huojialist = element.goods_shelf;
          this.$set(this.ruleForm, "warehouse", element.warehouse_name);
          // console.log(this.huojialist);
        }
      });
      // console.log(this.huojialist);
    },
    getcangku() {
      getWarehouseList().then((res) => {
        if (res.code == 200) {
          this.cangkulist = res.data.data;
        }
      });
    },

    // 导出
    exports_w() {
      if (this.dc_order_ids.length == 0) {
        this.$message.error("请选择导出项");
        return false;
      }
      let data = {
        ...this.ser,
        order_ids: this.dc_order_ids,
        export: 1,
      };
      downloadcode(data).then((res) => {
        //创建一个隐藏的a连接，
        const link = document.createElement("a");
        let blob = new Blob([res.data], { type: "application/vnd.ms-excel" });
        link.style.display = "none";
        //设置连接
        link.href = URL.createObjectURL(blob);
        link.download = "订单信息";
        document.body.appendChild(link);
        //模拟点击事件
        link.click();
      });
    },
    searchreset() {
      this.ser = {};
      this.getlist();
    },
    // 客户列表
    getCustomer() {
      getCustomerList({ per_page: 99999 }).then((res) => {
        if (res.code == 200) {
          this.CustomerList = res.data.data;
        }
      });
    },

    // 业务员列表
    getEmpl() {
      getYeWuYuanList().then((res) => {
        if (res.code == 200) {
          this.EmployeeList = res.data;
        }
      });
    },
    //产品列表
    getproduct() {
      // is_simple:1
      getProductList({ per_page: 1000 }).then((res) => {
        if (res.code == 200) {
          this.productList = res.data.data;
        }
      });
    },

    // del_product(row) {
    //  // console.log("ww");
    //   delColor({
    //     id: row.id,
    //     is_del: 1,
    //   }).then((res) => {
    //     if (res.code == 200) {
    //       this.isProduct = false;
    //       this.$message.success("提交成功");
    //       this.getlist();
    //     }
    //   });
    // },
    // toggleSelection(rows) {
    //   //使用$nextTick，保证dom已经更新
    //   this.$nextTick(() => {
    //     setTimeout(() => {
    //       //保证有值再进行比对，避免报错
    //       if (rows && this.dataList.length != 0) {
    //         //遍历table表格数据与要回显的数组比对，匹配成功的设置为选中状态
    //         this.dataList.forEach((row) => {
    //           rows.forEach((item) => {
    //             if (row.id == item.id) {
    //               //判断唯一标识，若是id一样，则设置该行选中状态为true
    //               this.$refs.multipleTable.toggleRowSelection(row, true);
    //             }
    //           });
    //         });
    //       } else {
    //         this.$refs.multipleTable.clearSelection();
    //       }
    //     }, 0);
    //   });
    // },
    getlist() {
      getOrderList({ ...this.pagination, ...this.ser }).then((res) => {
        if (res.code == 200) {
          this.dataList = res.data.data;
          this.total = res.data.total;
          this.loading = false;
          this.toggleSelection(this.dayinlist);
          console.log(this.dayinlist, "erreeee");
        }
      });
    },
    add_order_close() {
      this.ruleForm = {};
    },
    auto_maticGenerationOrderNumber() {
      automaticGenerationOrderNumber().then((res) => {
        this.ruleForm.order_number = res.data;
      });
    },

    submitadds(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.isjietu = true;
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    submitadd() {
      this.handleExport();
      createOrder(this.ruleForm).then((res) => {
        if (res.code == 200) {
          this.isProduct = false;
          this.isjietu = false;
          this.$message.success(
            "提交成功,进入审核流程,审核通过之后在订单列表查看~"
          );
          this.getlist();
        }
      });
    },
    handleCurrentChange(val) {
      this.pagination.page = val;
      this.getlist();
    },
    prev() {
      this.pagination.page = this.pagination.page - 1;
      this.getlist();
    },
    next() {
      this.pagination.page = this.pagination.page + 1;
      this.getlist();
    },
    //获取对应子订单信息
    getOrderChild(is_epibolys) {
      getOrderChildListByOrderId({
        ...this.push_prders,
        is_epiboly: is_epibolys,
      }).then((res) => {
        if (res.code == 200) {
          this.moreList = res.data;
        }
      });
    },
  },
};
</script>

<style scoped>
.list_order {
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: left;
}

.list_li {
  display: flex;
  height: 60px;
  flex-direction: column;
  justify-content: space-around;
}

.list_li .none {
  display: none;
}

.list_li .red {
  display: block;
  color: #cc1010;
}

.list_order .lis {
  width: 100%;
}

#printArea {
  height: 100%;
}

#printArea table tr td {
  width: 100%;
  display: flex;
  align-items: center;
}

#printArea table {
  border: 1px solid #c5c5c5;
}

#printArea table td {
  border: 1px solid #c5c5c5;
  text-align: center;
  padding: 0;
  margin: 0;
  padding: 0 5px;
  min-height: 30px;
  box-sizing: border-box;
}

#printArea table td span {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#printArea table td span:first-child {
  width: 150px;
  border-right: 1px solid #c5c5c5;
}

#printArea table td span:last-child {
  flex: 1;
}

.float_icon {
  position: absolute;
  left: 0px;
  top: 0;
  font-size: 26px;
}

.biaoji_radio >>> .el-radio__label {
  font-size: 30px;
}

.biaoji_radio >>> .el-radio__inner {
  width: 25px;
  height: 25px;
  border-radius: 25;
}

.el-radio__original {
}
</style>
